<template>
  <div id="appraise">
    <van-row>
      <van-col span="24">
        <van-nav-bar title="评价" left-text="返回" left-arrow @click-left="onClickLeft" />
      </van-col>
      <van-col span="24" class="box1">
        <van-tabs v-model="active" @change="onGetList(active)">
          <van-tab :title="tab" v-for="(tab, index) in vanTabList" :key="index">
            <van-col span="24" v-if="setList.length == 0">
              <van-empty image="search" description="暂无评论" />
            </van-col>
            <Comments v-else v-for="(item, index) in setList" :key="item.id" :avatarUrl="item.userInfo.avatarUrl" :nickName="item.userInfo.nickName" :addTime="item.addTime" :content="item.content" :picList="item.picList"></Comments>
          </van-tab>
        </van-tabs>
      </van-col>
    </van-row>
  </div>
</template>
<script>
import Comments from '@/components/user/comments/comments.vue'
export default {
  name,
  data() {
    return {
      active: 0,
      vanTabList: ['全部', '有图'],
      setList: {}
    }
  },
  components: {
    Comments
  },
  mounted() {
    this.onGetList(this.active)
  },
  methods: {
    onClickLeft() {
      this.$router.back()
    },
    onGetList(active) {
      console.log(this.$route.query)
      let data = {
        type: 0, //类型ID。 如果是0，则查询商品评论；如果是1，则查询专题评论。
        valueId: this.$route.query.id, //商品或专题ID。如果type是0，则是商品ID；如果type是1，则是专题ID
        showType: active //显示类型。如果是0，则查询全部；如果是1，则查询有图片的评论。
      }
      this.$get('comment/list', data)
        .then(result => {
          console.log(result.data.data.list)
          this.setList = result.data.data.list
        })
        .catch(err => {})
    }
  }
}
</script>
<style lang="less" scoped>
.box1 {
}
</style>
